var collision=0;//0: no collision 1: vertical solid 2: deadly 3:level completed
var collisionObj=0;
onFloor=false;
//solid
with(oSolid){
    //vertical checking
    if(rectOverlap(
            other.x,other.y+other.dy, other.x+other.sprite_width,other.y+other.sprite_height+other.dy,
            x,min(y,y+sprite_height),x+sprite_width,max(y,y+sprite_height)
    )){
        collision=max(1,collision);
        if(collision==1)
            collisionObj=id;//id : this self : class name
    }
    //horizontal checking
    if(rectOverlap(
            other.x+other.dx,other.y, other.x+other.sprite_width+other.dx,other.y+other.sprite_height,
            x,min(y,y+sprite_height),x+sprite_width,max(y,y+sprite_height)
    )){
        collision=2;
        collisionObj=id;
    }
}

//deadly objects
with(oDeadly) {
    if(oPlayer.aboveGround==aboveGround){
        if(rectOverlap(other.x+other.dx,other.y+other.dy,other.x+other.sprite_width+other.dx,
            other.y+other.sprite_height+other.dy,x+dx,y+dy,x+sprite_width+dx,y+sprite_height+dy
        )){
            collision=2;
            collisionObj=id;
        }
    }
}

//determine results
if(collision==1){
    dy=0;
    grav=0;
    onFloor=true;
    if(aboveGround)
        y=collisionObj.y-sprite_height;
    if(!aboveGround)
        y=collisionObj.y;
}
if(collision==2){
    room_restart();
    setMenuVisible(oGameControl.levelFinishedMenu, false);
}
